Skip to content

Wrap Infisical auth HTTPStatusError as ProviderError#23

Merged
jdoss merged 1 commit intomasterfrom
fix/infisical-auth-error-wrapping
Apr 8, 2026
Merged

Wrap Infisical auth HTTPStatusError as ProviderError#23
jdoss merged 1 commit intomasterfrom
fix/infisical-auth-error-wrapping

Conversation

@jdoss
Copy link
Copy Markdown
Contributor

@jdoss jdoss commented Apr 8, 2026

Summary

  • psi/providers/infisical/auth.py:_parse_token_response now wraps httpx.HTTPStatusError as ProviderError with the status code and a body snippet. Previously, a 502 from Infisical's auth endpoint (e.g. during its own boot) escaped through psi setup's retry loop and surfaced as the CLI bug-report panel. The wrap preserves __cause__ so setup._is_retryable still unwraps and retries 502/503/404.
  • psi/cli.py:main() gains an httpx.HTTPError catch as a last-resort fallback, so any stray httpx exception from future code paths lands as Error: Network error: … instead of "Internal error — this is a bug."

Test plan

  • pytest tests/test_infisical_auth.py — new: _parse_token_response happy path, 502 → ProviderError with cause, 401 with body snippet.
  • pytest tests/test_setup.py — new: 502 wrapped as ProviderError retries through all 6 attempts via __cause__ unwrap; 401 wrapped as ProviderError fails immediately (non-retryable).
  • pytest tests/test_cli_error_handling.py — new: httpx.ConnectError and httpx.HTTPStatusError escaping app() exit 1 with "Network error", not the bug panel.
  • ruff check / ruff format --check / ty check — all clean.

The error-handling cleanup in #7 wrapped lookup-path httpx errors but
missed psi/providers/infisical/auth.py:_parse_token_response. When
Infisical returned 502 during its own boot, the raw HTTPStatusError
escaped through psi setup's retry loop and surfaced as the CLI
bug-report panel instead of a clean error message.

Wrap the auth response in ProviderError with the status code and a body
snippet, preserving __cause__ so setup._is_retryable still unwraps and
retries 502/503/404. Add httpx.HTTPError as a last-resort catch in
cli.main() so any future stray httpx exception lands as "Network error"
instead of the bug panel.

Tests: unit coverage for _parse_token_response wrapping; setup retry
tests covering a 502 wrapped as ProviderError retrying through all
attempts and a 401 wrapped as ProviderError failing immediately; CLI
tests for the httpx fallback branch.
@jdoss jdoss merged commit e0e6736 into master Apr 8, 2026
2 checks passed
@jdoss jdoss deleted the fix/infisical-auth-error-wrapping branch April 9, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant